
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Set up
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

\usepackage[inner=2cm,outer=2cm,top=2.5cm,bottom=2.5cm]{geometry}
\pagestyle{empty}
\usepackage{graphicx}
\usepackage{fancyhdr, lastpage, bbding, pmboxdraw}
\usepackage[usenames,dvipsnames]{color}
\definecolor{darkblue}{rgb}{0,0,.6}
\definecolor{darkred}{rgb}{.7,0,0}
\definecolor{darkgreen}{rgb}{0,.6,0}
\definecolor{red}{rgb}{.98,0,0}
\usepackage[colorlinks,pdfusetitle,urlcolor=darkblue,citecolor=darkblue,linkcolor=black,bookmarksnumbered,plainpages=false]{hyperref} 

\renewcommand{\thefootnote}{\fnsymbol{footnote}}
\usepackage{amssymb}
\usepackage{pdfpages}
\usepackage{cmbright} % font of moderncv

\usepackage{etoolbox,refcount}
\usepackage{multicol}
\newcounter{countitems}
\newcounter{nextitemizecount}
\newcommand{\setupcountitems}{%
  \stepcounter{nextitemizecount}%
  \setcounter{countitems}{0}%
  \preto\item{\stepcounter{countitems}}%
}
\makeatletter
\newcommand{\computecountitems}{%
  \edef\@currentlabel{\number\c@countitems}%
  \label{countitems@\number\numexpr\value{nextitemizecount}-1\relax}%
}
\newcommand{\nextitemizecount}{%
  \getrefnumber{countitems@\number\c@nextitemizecount}%
}
\newcommand{\previtemizecount}{%
  \getrefnumber{countitems@\number\numexpr\value{nextitemizecount}-1\relax}%
}
\makeatother    
\newenvironment{AutoMultiColItemize}{%
\ifnumcomp{\nextitemizecount}{>}{3}{\begin{multicols}{2}}{}%
\setupcountitems\begin{itemize}}%
{\end{itemize}%
\unskip\computecountitems\ifnumcomp{\previtemizecount}{>}{3}{\end{multicols}}{}}

\usepackage{xcolor}
\usepackage{framed} 
\colorlet{shadecolor}{gray!80} 

\usepackage{tikzsymbols}
\usepackage{soul} % for highlighting
\usepackage{graphicx,wrapfig,lipsum}

\usepackage[german,english]{babel} 
\usepackage[utf8]{inputenc}
\usepackage{setspace}
\onehalfspacing

\usepackage{blindtext}
\usepackage{lipsum}  

\usepackage{fontawesome}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Adjust to have a running header with the course title
\pagestyle{fancyplain}
\fancyhf{}

\chead{Course title} % Change the course title

\rfoot{\fancyplain{}{\footnotesize \thepage /\pageref{LastPage}}}
\thispagestyle{plain}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Citation
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

\usepackage[style=authoryear,backend=biber,uniquename=false]{biblatex}

\DeclareNameAlias{sortname}{family-given}
\DeclareNameAlias{default}{family-given}

\renewbibmacro*{journal+issuetitle}{% 
  \usebibmacro{journal}% 
  \setunit*{\addspace}% 
  \iffieldundef{series} 
    {} 
    {\newunit 
     \printfield{series}% 
     \setunit{\addspace}}% 
  \printfield{volume}% 
  \iffieldundef{number} 
     {} 
      {\mkbibparens{\printfield{number}}}% 
  \setunit{\addcomma\space}% 
  \printfield{eid}% 
  \setunit{\addspace}% 
  \usebibmacro{issue+date}% 
  \setunit{\addcolon\space}% 
  \usebibmacro{issue}% 
  \newunit}
% remove "In:" before journal
\makeatletter
\renewbibmacro*{in:}{%
\def\tempb{article}
\ifx\abx@field@entrytype\tempb
  \else%
  \printtext{%
    \bibstring{in}\intitlepunct}
 \fi
}
\makeatother

%removing automatic comma and p./pp. from in-line citations
\DeclareFieldFormat{postnote}{#1} 
% add ":" instead of "pp."
\renewcommand*{\bibpagespunct}{\addcolon} 
\DeclareFieldFormat{pages}{ #1} 
% removes urldate as fallback date and enables n.d. if no date is given
\newcommand{\mkbibnodate}{n\adddot d\adddot}
\AtEveryCitekey{\iffieldundef{labelyear}{\restorefield{labelyear}{\mkbibnodate}}{}}
\AtEveryBibitem{\iffieldundef{labelyear}{\restorefield{year}{\mkbibnodate}}{}}

\bibliography{literature.bib}

\usepackage{bibentry}
\usepackage{csquotes}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% LISTING %%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\usepackage{listings}
\usepackage{caption}
\DeclareCaptionFont{white}{\color{white}}
\DeclareCaptionFormat{listing}{\colorbox{gray}{\parbox{\textwidth}{#1#2#3}}}
\usepackage{verbatim} % used to display code
\usepackage{fancyvrb}
\usepackage{acronym}
\usepackage{amsthm}
\VerbatimFootnotes % Required, otherwise verbatim does not work in footnotes!


\lstset{
basicstyle=\ttfamily,                   % Code font, Examples: \footnotesize, \ttfamily
keywordstyle=\color{OliveGreen},        % Keywords font ('*' = uppercase)
commentstyle=\color{gray},              % Comments font
numbers=left,                           % Line nums position
numberstyle=\tiny,                      % Line-numbers fonts
stepnumber=1,                           % Step between two line-numbers
numbersep=5pt,                          % How far are line-numbers from code
backgroundcolor=\color{lightlightgray}, % Choose background color
frame=none,                             % A frame around the code
tabsize=2,                              % Default tab size
captionpos=t,                           % Caption-position = bottom
breaklines=true,                        % Automatic line breaking?
breakatwhitespace=false,                % Automatic breaks only at whitespace?
showspaces=false,                       % Dont make spaces visible
showtabs=false,                         % Dont make tabls visible
columns=flexible,                       % Column format
morekeywords={__global__, __device__},  % CUDA specific keywords
}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
